package com.hjm.project.merchantInfo.total.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.merchantInfo.total.domain.MerchantTotal;
import com.hjm.project.merchantInfo.total.service.IMerchantTotalService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 商户信息统计Controller
 * 
 * @author LOVE
 * @date 2020-12-07
 */
@Controller
@RequestMapping("/merchantInfo/total")
public class MerchantTotalController extends BaseController
{
    private String prefix = "merchantInfo/total";

    @Autowired
    private IMerchantTotalService merchantTotalService;

    @RequiresPermissions("merchantInfo:total:view")
    @GetMapping()
    public String total()
    {
        return prefix + "/total";
    }

    /**
     * 查询商户信息统计列表
     */
    @RequiresPermissions("merchantInfo:total:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(MerchantTotal merchantTotal)
    {
        startPage();
        List<MerchantTotal> list = merchantTotalService.selectMerchantTotalList(merchantTotal);
        return getDataTable(list);
    }

    /**
     * 导出商户信息统计列表
     */
    @Log(title = "商户信息统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MerchantTotal merchantTotal)
    {
        List<MerchantTotal> list = merchantTotalService.selectMerchantTotalList(merchantTotal);
        ExcelUtil<MerchantTotal> util = new ExcelUtil<MerchantTotal>(MerchantTotal.class);
        return util.exportExcel(list, "total");
    }

    /**
     * 导出商户信息统计列表
     */
    @Log(title = "商户信息统计", businessType = BusinessType.EXPORT)
    @PostMapping("/exportAgentDetail")
    @ResponseBody
    public AjaxResult exportAgentDetail(MerchantTotal merchantTotal)
    {
        List<MerchantTotal> list = merchantTotalService.selectMerchantTotalList(merchantTotal);
        ExcelUtil<MerchantTotal> util = new ExcelUtil<MerchantTotal>(MerchantTotal.class);
        return util.exportExcel(list, "total");
    }

    /**
     * 新增商户信息统计
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存商户信息统计
     */
    @RequiresPermissions("merchantInfo:total:add")
    @Log(title = "商户信息统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(MerchantTotal merchantTotal)
    {
        return toAjax(merchantTotalService.insertMerchantTotal(merchantTotal));
    }

    /**
     * 修改商户信息统计
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        MerchantTotal merchantTotal = merchantTotalService.selectMerchantTotalById(id);
        mmap.put("merchantTotal", merchantTotal);
        return prefix + "/edit";
    }

    /**
     * 修改保存商户信息统计
     */
    @RequiresPermissions("merchantInfo:total:edit")
    @Log(title = "商户信息统计", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MerchantTotal merchantTotal)
    {
        return toAjax(merchantTotalService.updateMerchantTotal(merchantTotal));
    }

    /**
     * 删除商户信息统计
     */
    @RequiresPermissions("merchantInfo:total:remove")
    @Log(title = "商户信息统计", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(merchantTotalService.deleteMerchantTotalByIds(ids));
    }
}
